-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(checkbox): submit on enter rather than toggle #11584
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small nits and one question. Thank you for getting this PR posted so quickly (and for tests)!
make enter keypress submit form rather than toggle checkbox Fixes: angular#11583
24df4a8
to
1944cbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
var form = $mdUtil.getClosest(ev.target, 'form'); | ||
// We have to use a native event here as the form directive does not use jqlite | ||
if (form) { | ||
form.dispatchEvent(new Event('submit')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this can possibly submit the form even when the button of type="submit"
is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to align with the native behavior where pressing enter in an input
will submit the form even if the form has no button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More investigation and follow up in #11639.
make enter keypress submit form rather than toggle checkbox
Fixes: #11583
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently if you have a checkbox focused and press enter, you toggle the value of the checkbox.
Issue Number: #11583
What is the new behavior?
Now pressing enter while focusing a checkbox within a form, the form will be submitted. If no form exists, nothing will happen.
Does this PR introduce a breaking change?
Other information
N/A